import request from '@/utils/request'

export interface DeviceUsageAnalysis {
    category: string | null;
    department: string | null;
    deviceCount: number | null;
    totalDuration: number | null;
    totalTimes: number | null;
    deviceName: string | null;
    deviceModel: string | null;
    todayUsageDuration: number | null;
}

export const deviceUsageApi = {

    getDepartmentUsageCount: () => {
        return request({
            method: 'GET',
            url: `/procedure/deviceUsageAnalysis/departmentCount`
        }).then(res => res.data)  // 直接返回 data 部分
    },

    getCategoryStats: () => {
        return request({
            method: 'GET',
            url: `/procedure/deviceUsageAnalysis/categoryStats`
        }).then(res => res.data)
    },

    getTodayHighUsageWarningList: (threshold: number) => {
        return request({
            method: 'GET',
            url: `/procedure/deviceUsageAnalysis/todayHighUsageWarning`,
            params: { todayDurationThreshold: threshold }
        }).then(res => res.data)
    },

    getTodayCategoryUsage: () => {
        return request({
            method: 'GET',
            url: `/procedure/deviceUsageAnalysis/todayCategoryUsage`
        }).then(res => res.data)
    }
}
